"""
    UI lookup additions.
"""

from sqlobject import DatabaseIndex
from sqlobject.col import UnicodeCol, ForeignKey, IntCol
from mnemoply.model.model_object import ModelObject
from mnemoply.model.hub import __connection__

class UserFilter(ModelObject):
    """
        Each user may create a lot of filters for different lookups.
        This class contains information about this.
    """

    model_title = _("UserFilter")

    name = UnicodeCol(length=80, notNull=True, title=_("Name"))
    url = UnicodeCol(length=2048, notNull=True, title=_("URL"))
    user = ForeignKey('AuthUser', notNull=True, title=_("User"))
    controller = UnicodeCol(length=80, notNull=True, title=_("Controller"))
    ordinal = IntCol(default=None, title=_("Ordinal"))

    userFilterUnique = DatabaseIndex('name', 'user', 'controller', unique=True)

    title = property(lambda self: "%s %s %s" % (self.name, self.user, self.controller))
